package com.meichis.yndms.vm;

import androidx.lifecycle.MutableLiveData;

import com.meichis.mcsappframework.utils.DateUtil;
import com.meichis.yndms.model.FeedBack;
import com.meichis.yndms.repository.manager.TerminalFeedbackManagert;

import java.util.List;

public class TerminalFeedbackVm extends MyViewModel {

    private MutableLiveData<String> BeginTime;
    private MutableLiveData<String> EndTime;

    private MutableLiveData<Integer> state;

    private MutableLiveData<List<FeedBack>> feedBackListData;

    public MutableLiveData<List<FeedBack>> getFeedBackListData() {
        if (feedBackListData == null) {
            feedBackListData = new MutableLiveData<>();
        }
        return feedBackListData;
    }

    public MutableLiveData<Integer> getState() {
        if (state == null) {
            state = new MutableLiveData<>();
            state.setValue(0);
        }
        return state;
    }

    public MutableLiveData<String> getBeginTime() {
        if (BeginTime == null) {
            BeginTime = new MutableLiveData<>();
            BeginTime.setValue(DateUtil.getMultipleDay(DateUtil.getCurDateStr(DateUtil.FORMAT_YMD), -15));
        }

        return BeginTime;
    }

    public MutableLiveData<String> getEndTime() {
        if (EndTime == null) {
            EndTime = new MutableLiveData<>();
            EndTime.setValue(DateUtil.getMultipleDay(DateUtil.getCurDateStr(DateUtil.FORMAT_YMD), 15));
        }
        return EndTime;
    }

    public void GetMyFeedbackList() {
        TerminalFeedbackManagert.getInstance().GetMyFeedbackList(getShowDialog(), getUserInfo().getValue().getOrgId(), getState().getValue(), getBeginTime().getValue(), getEndTime().getValue(), getFeedBackListData());
    }
}
